import { request } from './index';

// 创建定单
export const createOrder = (params) => {
    return request({
        url: '/api/orders',
        method: 'post',
        params
    })
}

// 获取定单预览
export const getOrderPreview = () => {
    return request({
        url: '/api/orders/preview'
    })
}

// 定单支付, 获取二维
export const payOrder = (order, params) => {
    return request({
        url: `/api/orders/${order}/pay`,
        params
    })
}

// 定单状态
export const payOrderStatus = (order) => {
    return request({
        url: `/api/orders/${order}/status`
    })
}

// 获取定单列表 {page:1, status:2, include:'user,orderDetail.goods'}
export const getOrderList = (params) => {
    return request({
        url: '/api/orders',
        method: 'get',
        params
    })
}

// 定单详情
export const getOrderDetail = (order) => {
    return request({
        url: `/api/orders/${order}`,
        params: {
            include: 'user,orderDetails.goods'
        }
    })
}

// 确认定单
export const confirmOrder = (order) => {
    return request({
        url: `/api/orders/${order}/confirm`,
        method: 'patch'
    })
}

// 获取物流信息 /api/orders/{order}/express
export const viewExpress = (order) => {
    return request({
        url: `/api/orders/${order}/express`
    })
}